package hn.cch.apache.commons.lang3;

import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StopWatchDemo {

    private final static Logger logger = LoggerFactory.getLogger(StopWatchDemo.class);


    public static void main(String[] args) throws InterruptedException {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        for (int i = 0; i < 1; i++) {

            Thread.sleep(1000);
            stopWatch.split();
            logger.info("getSplitTime:{}", stopWatch.getSplitTime());

        }
        Thread.sleep(1000);
        stopWatch.stop();
        logger.info("getTime:{}", stopWatch.getTime());
        stopWatch.reset();

        stopWatch.start();
        Thread.sleep(1000);
        stopWatch.suspend();
        Thread.sleep(1000);
        stopWatch.resume();
        Thread.sleep(1000);
        stopWatch.stop();
        logger.info("getTime:{}", stopWatch.getTime());
    }
}
